/*
 * @Description: 
 * @Author: 胡涛
 * @Date: 2023-09-26 09:04:13
 * @LastEditors: 胡涛
 * @LastEditTime: 2023-12-18 22:50:12
 */
import cookie from "@/helpers/cookie";
import { useAppStore } from "@/store";
export const TOKEN_AUTH_TIME_KEY = "tokenAuthRefreshTime"

export const useLoadingCheck = () => {
  const loading = document.querySelector("body > #loading-app");
  if (loading) {
    const body = document.querySelector("body");
    setTimeout(() => {
      body?.removeChild(loading);
    }, 100);
  }
};

/**
 *  检查token是否过期
 * @returns 
 */
export async function checkloadingToken() {
  let value = cookie.get(TOKEN_AUTH_TIME_KEY);
  //根据cookie判断是否需要清除登录信息
  if (!value) {
    useAppStore().logout();
  }
}
